home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / bc_ti.zip / TI452.ASC < prev    next >
Text File  |  1992-02-25  |  2KB  |  67 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.   PRODUCT  :  TURBO C                                NUMBER  :  452
  8.   VERSION  :  2.O
  9.        OS  :  PC-DOS
  10.      DATE  :  FEBRUARY 2, 1989                         PAGE  :  1/1
  11.  
  12.     TITLE  :  ERASING CHARACTERS (OR "TEXT")
  13.  
  14.  
  15.  
  16.  
  17.   The  following  program  demonstrates  two  methods  of  removing
  18.   previously displayed characters.    The first method uses the bar
  19.   function to erase  the  desired  area  of the screen.  The second
  20.   method involves overwriting the font  in  the  current background
  21.   color.  Both methods  are  effective,  and  the choice of methods
  22.   would be based on the needs of the particular application.
  23.  
  24.  
  25.   #include <graphics.h>
  26.   #include <dos.h>
  27.  
  28.   main()
  29.   {
  30.     int driver = DETECT;        /* autodetect driver          */
  31.     int mode;
  32.     int oldcolor;
  33.     int x=10;
  34.     int y=10;
  35.     char string1[] = "Hello";
  36.     char string2[] = "world";
  37.     char string3[] = "Goodbye";
  38.  
  39.     initgraph(&driver, &mode, "");
  40.  
  41.     outtextxy(x, y, string1);   /* print a string             */
  42.     sleep(1);                   /* wait a second              */
  43.  
  44.     /*** erase text by drawing a bar ***/
  45.     setfillstyle(SOLID_FILL, getbkcolor());
  46.     bar(x, y, x+textwidth(string1), y+textheight(string1));
  47.  
  48.     outtextxy(x, y, string2);   /* print another string       */
  49.     sleep(1);                   /* wait another second        */
  50.  
  51.     /*** erase the string by overwriting ***/
  52.     oldcolor = getcolor();      /* save current color         */
  53.     setcolor( getbkcolor() );   /* set to background color    */
  54.     outtextxy(x, y, string2);   /* erase string               */
  55.     setcolor(oldcolor);         /* restore color              */
  56.  
  57.     outtextxy(x, y, string3);   /* print one more string      */
  58.     sleep(1);                   /* wait one more second       */
  59.  
  60.     closegraph();
  61.     return 0;
  62.   }
  63.  
  64.  
  65.  
  66.  
  67.